{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "14fe1a64",
   "metadata": {},
   "source": [
    "# Feature Adversaries Attack in TensorFlow v2\n",
    "\n",
    "Before diving into the attack, let's first prepare a classification model. We utilize a script from the `examples` folders."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "33edf2bc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy on benign test examples: 96.77%\n"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import tensorflow as tf\n",
    "from tensorflow.keras import Sequential\n",
    "from tensorflow.keras.layers import Dense, Flatten, Conv2D, MaxPool2D\n",
    "\n",
    "from art.attacks.evasion import FeatureAdversariesTensorFlowV2\n",
    "from art.estimators.classification import TensorFlowV2Classifier\n",
    "from art.utils import load_mnist\n",
    "\n",
    "# Step 1: Load the MNIST dataset\n",
    "\n",
    "(x_train, y_train), (x_test, y_test), min_pixel_value, max_pixel_value = load_mnist()\n",
    "\n",
    "# Step 1a: Cast to np.float32\n",
    "x_train = x_train.astype(np.float32)\n",
    "x_test = x_test.astype(np.float32)\n",
    "\n",
    "# Step 2: Create the model\n",
    "\n",
    "model = Sequential()\n",
    "model.add(Conv2D(filters=4, kernel_size=5, activation=\"relu\"))\n",
    "model.add(MaxPool2D(pool_size=(2, 2), padding=\"valid\", data_format=None))\n",
    "model.add(Conv2D(filters=10, kernel_size=5, activation=\"relu\"))\n",
    "model.add(MaxPool2D(pool_size=(2, 2), padding=\"valid\", data_format=None))\n",
    "model.add(Flatten())\n",
    "model.add(Dense(100))\n",
    "model.add(Dense(10))\n",
    "\n",
    "# Step 2a: Define the loss function and optimizer\n",
    "\n",
    "loss_object = tf.keras.losses.CategoricalCrossentropy(from_logits=True)\n",
    "optimizer = tf.keras.optimizers.Adam(learning_rate=0.01)\n",
    "\n",
    "# Step 3: Create the ART classifier\n",
    "\n",
    "classifier = TensorFlowV2Classifier(\n",
    "    model=model,\n",
    "    loss_object=loss_object,\n",
    "    optimizer=optimizer,\n",
    "    nb_classes=10,\n",
    "    input_shape=(28, 28, 1),\n",
    "    clip_values=(0, 1),\n",
    ")\n",
    "\n",
    "# Step 4: Train the ART classifier\n",
    "\n",
    "classifier.fit(x_train, y_train, batch_size=64, nb_epochs=3)\n",
    "\n",
    "# Step 5: Evaluate the ART classifier on benign test examples\n",
    "\n",
    "predictions = classifier.predict(x_test)\n",
    "accuracy = np.sum(np.argmax(predictions, axis=1) == np.argmax(y_test, axis=1)) / len(y_test)\n",
    "print(\"Accuracy on benign test examples: {}%\".format(accuracy * 100))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d9da5b77",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "## PGD variant of Feature Adversaries\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "cb695872",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Step 5: prepare a batch of source and guide images\n",
    "valid = np.argmax(y_test, axis=1)[:100] != np.argmax(y_test, axis=1)[100:200]\n",
    "source = x_test[:100][valid][:32]\n",
    "guide = x_test[100:200][valid][:32]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c8586dfa",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d5bf0d366f9d4d19904dc7e6c1478d71",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Feature Adversaries TensorFlow v2:   0%|          | 0/100 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy on adversarial test batch: 0.0%\n",
      "Average perturbation: 0.17647060751914978%\n"
     ]
    }
   ],
   "source": [
    "# Step 6: Generate adversarial test examples\n",
    "attack = FeatureAdversariesTensorFlowV2(\n",
    "    classifier,\n",
    "    layer=-2,\n",
    "    delta=45/255,\n",
    "    optimizer=None,\n",
    "    step_size=1/255,\n",
    "    max_iter=100,\n",
    ")\n",
    "x_test_adv = attack.generate(source, guide)\n",
    "\n",
    "# Step 7: Evaluate the ART classifier on adversarial test examples\n",
    "\n",
    "predictions = classifier.predict(x_test_adv)\n",
    "accuracy = np.sum(np.argmax(predictions, axis=1) == np.argmax(y_test[:100][valid][:32], axis=1)) / len(y_test[:100][valid][:32])\n",
    "\n",
    "dim = tuple(range(1, len(source.shape)))\n",
    "pert = np.mean(np.amax(np.abs(source - x_test_adv), axis=dim))\n",
    "print(\"Accuracy on adversarial test batch: {}%\".format(accuracy * 100))\n",
    "print(\"Average perturbation: {}%\".format(pert))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "68717bc9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe400651d30>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAATpElEQVR4nO3dbYxc1XkH8P9/Ztdee/26Nl6M7YABY8fgZGk2kBYUkbqhQNoAX2iQmtKK1pEKUqLSCko+hH6oRKuQiA8VkhNInCoFRQKEo1ohxElrQcDFpgbbGGPjGGGzfsE22Phld2fm6Ycd0wX2PGeZO3fu2Of/k1a7e5859x5fz7N3Zp57zqGZQUTOfqWiOyAiraFkF0mEkl0kEUp2kUQo2UUS0dHKg03gROtCdysPeWYg/XBH2Y1bpdrM3nxk521crZkyyY+/f7I1/Wgjp3AcQzY45hMqU7KTvA7AgwDKAH5oZvd7j+9CN67k8iyHPCtx4kQ3Xu6Z6carh480szsfYoODue07K+vrc+N8blNL+tFO1tvaYKzh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gglu0giWlpnJ3kQwJujNs0GEJ5ruFjt2rd27RegvjWqmX0738zOGSvQ0mT/2MHJDWbWX1gHHO3at3btF6C+NapVfdPLeJFEKNlFElF0sq8s+Piedu1bu/YLUN8a1ZK+FfqeXURap+gru4i0iJJdJBGFJDvJ60huJ7mT5D1F9CGE5G6Sm0luIrmh4L48QvIAyS2jtvWQfIbkjvr3MdfYK6hv95HcWz93m0jeUFDfFpD8DclXSW4l+c369kLPndOvlpy3lr9nJ1kG8DqALwPYA+BFALea2ast7UgAyd0A+s2s8BswSH4RwPsAfmJml9W3/SuAw2Z2f/0P5Uwzu7tN+nYfgPeLXsa7vlrR3NHLjAO4CcBfosBz5/TrFrTgvBVxZb8CwE4z22VmQwAeA3BjAf1oe2a2DsDhj2y+EcCq+s+rMPJkablA39qCmQ2Y2Uv1n48BOL3MeKHnzulXSxSR7PMAvDXq9z1or/XeDcAvSW4kuaLozoyh18wG6j/vA9BbZGfGEF3Gu5U+ssx425y7RpY/z0of0H3c1Wb2ewCuB3BH/eVqW7KR92DtVDsd1zLerTLGMuMfKPLcNbr8eVZFJPteAAtG/T6/vq0tmNne+vcDAJ5E+y1Fvf/0Crr17wcK7s8H2mkZ77GWGUcbnLsilz8vItlfBLCI5EKSEwB8DcDqAvrxMSS76x+cgGQ3gGvRfktRrwZwW/3n2wA8VWBfPqRdlvEOLTOOgs9d4cufm1nLvwDcgJFP5N8A8O0i+hDo14UAXq5/bS26bwAexcjLumGMfLZxO4BZANYC2AHgVwB62qhv/w5gM4BXMJJYcwvq29UYeYn+CoBN9a8bij53Tr9act50u6xIIvQBnUgilOwiiVCyiyRCyS6SCCW7SCKU7CKJULKLJOL/AOZEFlaLZkV4AAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Step 8: Inspect results\n",
    "\n",
    "# orig 7, guide 6\n",
    "plt.imshow(x_test_adv[0,...].squeeze())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "5aabd4ae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe40053a4c0>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAR0klEQVR4nO3dbYxc5XUH8P9/Z9c2fiFlsVk5xry5ToN5W5LFTQFVJKiRoVUNqkqD2shVUR21QU2kKCqiH8KHqEJVkyhqKyonIEyVEkUlCH+gLdRCcYGEsJDFrySAsw5r7LXBBtY29u7MnH7YS7rA3vMsc+fOHTj/n7Ta2XvmuffZ6z2+M3Pu8zw0M4jIh19P1R0Qkc5QsosEoWQXCULJLhKEkl0kiN5OHmwe59sCLOrkIUWqsfg0P37srVIOexLHMWmnOFusULKTXAfg2wBqAL5rZnd6z1+ARfhtXlvkkCKdwVnz5f8lStY2OOjv/omR99efOXrKtubGWn4ZT7IG4F8AXAdgDYCbSa5pdX8iUq4i79nXAnjRzPaa2SSA7wNY355uiUi7FUn2FQBenvHzWLbtHUhuJDlMcngKpwocTkSKKP3TeDPbZGZDZjbUh/llH05EchRJ9v0AVs74+exsm4h0oSLJ/jSA1STPJzkPwOcAbGlPt0Sk3VouvZlZneStAP4b06W3e8xsV9t6Jh8IvSvPLm3f9ZfH/Cf01Nyw/c4lubFk6StVWrtq0G+f4LUvqyxXqM5uZg8DeLhNfRGREul2WZEglOwiQSjZRYJQsosEoWQXCULJLhJER8ezy4dPs3+JG7fe/OuJPePfllG0ll1k32XVuju1/9noyi4ShJJdJAglu0gQSnaRIJTsIkEo2UWCUOlNXD0LF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KLBNHZJZubTTQnJnLj7Gu9rlqk7VzY1GSp+//A6qm54cbRN1redarC37NwoX/sEmvpyTp62UNkW6Aru0gQSnaRIJTsIkEo2UWCULKLBKFkFwlCyS4SBM2scwcjDwPYN2PTUgCvdqwD70+39q1b+wWob61qZ9/ONbNlswU6muzvOTg5bGZDlXXA0a1969Z+AepbqzrVN72MFwlCyS4SRNXJvqni43u6tW/d2i9AfWtVR/pW6Xt2Eemcqq/sItIhSnaRICpJdpLrSP6c5Iskb6uiD3lIjpLcQXKE5HDFfbmH5CGSO2ds6yf5KMkXsu+zrrFXUd/uILk/O3cjJK+vqG8rST5GcjfJXSS/lG2v9Nw5/erIeev4e3aSNQC/APB7AMYAPA3gZjPb3dGO5CA5CmDIzCq/AYPk7wI4BuA+M7s42/YPAI6Y2Z3Zf5RnmNnfdknf7gBwrOplvLPVipbPXGYcwA0A/hwVnjunXzehA+etiiv7WgAvmtleM5sE8H0A6yvoR9czs20Ajrxr83oAm7PHmzH9x9JxOX3rCmZ2wMyezR5PAHh7mfFKz53Tr46oItlXAHh5xs9j6K713g3AIySfIbmx6s7MYsDMDmSPDwIYqLIzs0gu491J71pmvGvOXSvLnxelD+je62oz+wSA6wB8MXu52pVs+j1YN9VO57SMd6fMssz4r1V57lpd/ryoKpJ9P4CVM34+O9vWFcxsf/b9EIAH0X1LUY+/vYJu9v1Qxf35tW5axnu2ZcbRBeeuyuXPq0j2pwGsJnk+yXkAPgdgSwX9eA+Si7IPTkByEYDPovuWot4CYEP2eAOAhyrsyzt0yzLeecuMo+JzV/ny52bW8S8A12P6E/mXAPxdFX3I6dcFAJ7LvnZV3TcA92P6Zd0Upj/buAXAmQC2AngBwP8A6O+ivv0bgB0AtmM6sZZX1LerMf0SfTuAkezr+qrPndOvjpw33S4rEoQ+oBMJQskuEoSSXSQIJbtIEEp2kSCU7CJBKNlFgvg/QTaDSnfAmcIAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# orig 1, guide 5\n",
    "plt.imshow(x_test_adv[2,...].squeeze())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1765536f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe400522700>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAUSklEQVR4nO3de4xc1X0H8O93Z9c2Xgz2+sViTGyDDbGh2GFjYkAUREEEUgEqpQEauRKKUwEVNBRBidRQVa3oA2hUAY0TEE6bmkYlCFRREmJFcQOBssbGD0zxAxvW2F6/4vdjZ+bXP3ZoF7Pnd5a5c2fGPd+PZO3u/e259+yd+fnOzO+ec2hmEJH//1oa3QERqQ8lu0gilOwiiVCyiyRCyS6SiNZ6HmwYh9sItNfzkCKDaz/Jjx88XJ9+1NgRHMQxO8rBYpmSneQ1AL4DoADg+2b2sPf7I9COi3hllkN6nfHjsRJjrH0WeZc3vb438u8eyvHz5PxtNvs3/Ka/Wlnr3hzXgXzOyxu2JBir+mU8yQKAxwF8GcBMALeQnFnt/kQkX1nes88FsN7MNprZMQDPAri+Nt0SkVrLkuyTAHw44OeeyrZPILmAZDfJ7j4czXA4Ecki90/jzWyhmXWZWVcbhud9OBEJyJLsWwBMHvDzGZVtItKEsiT7mwCmk5xKchiArwJ4sTbdEpFaq7r0ZmZFkncB+An6S29Pm9mamvXsM2Kh4MatWPR3kKUUknf5KiZL3xtdmsuRzfPLa1na5l6ay0GmOruZvQTgpRr1RURypNtlRRKhZBdJhJJdJBFKd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n6wQF2T/VMHJ7vNrKthHXA0a9+atV+A+latevVNL+NFEqFkF0lEo5N9YYOP72nWvjVrvwD1rVp16VtD37OLSP00+souInWiZBdJREOSneQ1JP+b5HqSDzSiDyEkN5FcRXIFye4G9+Vpkr0kVw/Y1kHyFZLrKl8HXWOvQX17iOSWyrlbQfLaBvVtMsmfk3yH5BqSd1e2N/TcOf2qy3mr+3t2kgUA7wG4CkAPgDcB3GJm79S1IwEkNwHoMrOG34BB8jIABwD8wMzOq2z7GwC7zezhyn+UY8zs/ibp20MADjR6Ge/KakWdA5cZB3ADgD9AA8+d06+bUYfz1ogr+1wA681so5kdA/AsgOsb0I+mZ2ZLAew+bvP1ABZVvl+E/idL3QX61hTMbKuZvVX5fj+Aj5cZb+i5c/pVF41I9kkABq6904PmWu/dAPyU5DKSCxrdmUFMNLOtle+3AZjYyM4MIrqMdz0dt8x405y7apY/z0of0H3apWb2BQBfBnBn5eVqU7L+92DNVDsd0jLe9TLIMuP/q5Hnrtrlz7NqRLJvATB5wM9nVLY1BTPbUvnaC+B5NN9S1Ns/XkG38jU8o2OdNdMy3oMtM44mOHeNXP68Ecn+JoDpJKeSHAbgqwBebEA/PoVke+WDE5BsB3A1mm8p6hcBzK98Px/ACw3syyc0yzLeoWXG0eBz1/Dlz82s7v8AXIv+T+Q3APhWI/oQ6Nc0AG9X/q1pdN8ALEb/y7o+9H+2cTuAsQCWAFgH4GcAOpqob/8EYBWAlehPrM4G9e1S9L9EXwlgReXftY0+d06/6nLedLusSCL0AZ1IIpTsIolQsoskQskukgglu0gilOwiiVCyiyTifwBk7FryZGBX8AAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# orig 4, guide 9\n",
    "plt.imshow(x_test_adv[4,...].squeeze())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1361622b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe400488250>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAUc0lEQVR4nO3df2xcVXYH8O+ZsZ0fzk87YEySzS8nhEAXs3gTfrWA6CIWqZtsVVEQQlkV1csWJFDRCpRSLX/SwkKRut1uKBGhoqDV7lIilRayydJ0+ZHgsM7vgEnWIXGc2EkIcRwn9syc/uFHa8D33GHezLyJ7/cjRTN+Z+57N+M5fjNz3r1XVBVENPalku4AEZUHk50oEEx2okAw2YkCwWQnCkRVOQ9WI+N0PGrLeciKIBPGm3EdOFumntBYdxb9GNRzMlosVrKLyK0AngGQBvAvqvq49fjxqMUyuTnOIc9LqabFZjy3c2+ZekJj3Wbd4IwV/DZeRNIAfgLg2wCWALhTRJYUuj8iKq04n9mXAvhIVfer6iCAlwEsL063iKjY4iT7TAAHR/x8KNr2OSLSKiJtItI2hHMxDkdEcZT823hVXa2qLaraUo1xpT4cETnESfYuALNH/Dwr2kZEFShOsr8HYKGIzBORGgB3AFhXnG4RUbEVXHpT1YyI3A/gdQyX3tao6q6i9ew8otc1m/Gsbwee9vJW+1fozXlERi0H/z/fiExf+zjG4GjQWHV2VX0NwGtF6gsRlRAvlyUKBJOdKBBMdqJAMNmJAsFkJwoEk50oEGUdz06jG7N1dJ+4tewk6/DnIZ7ZiQLBZCcKBJOdKBBMdqJAMNmJAsFkJwpERZXe0pcuNOO5iTXOmG6NN7rWN0w1jlKX1lJXXOqMZSeVdnagql2/N+PZk586Y+np0822OjhoxlNTJpvxOLK9x8y4ZjIlO3ap8MxOFAgmO1EgmOxEg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SLSlnBf1ohIj4jsHLGtTkTWi0hHdDvqGnsJ9e0xEemKnrt2Ebktob7NFpHfiMhuEdklIg9E2xN97ox+leV5K/tndhFJA/gQwLcAHALwHoA7VXV3WTviICKdAFpUNfELMETkjwCcBvCCql4ebft7ACdU9fHoD+V0VX24Qvr2GIDTSS/jHa1W1DhymXEAKwB8Dwk+d0a/bkcZnrckzuxLAXykqvtVdRDAywCWJ9CPiqeqmwCc+MLm5QDWRvfXYvjFUnaOvlUEVe1W1fej+30APltmPNHnzuhXWSSR7DMBHBzx8yFU1nrvCuANEdkqIq1Jd2YUDaraHd0/AqAhyc6MwruMdzl9YZnxinnuCln+PC5+Qfdl16vqNwB8G8B90dvViqTDn8EqqXaa1zLe5TLKMuP/J8nnrtDlz+NKItm7AMwe8fOsaFtFUNWu6LYHwCuovKWoj362gm50W7oZH7+iSlrGe7RlxlEBz12Sy58nkezvAVgoIvNEpAbAHQDWJdCPLxGR2uiLE4hILYBbUHlLUa8DsDK6vxLAqwn25XMqZRlv1zLjSPi5S3z5c1Ut+z8At2H4G/l9AP4miT44+jUfwLbo366k+wbgJQy/rRvC8Hcb9wCoB7ABQAeAXwOoq6C+/SuAHQC2YzixGhPq2/UYfou+HUB79O+2pJ87o19led54uSxRIPgFHVEgmOxEgWCyEwWCyU4UCCY7USCY7ESBYLITBeJ/AZfSQRCI6e66AAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# orig 4, guide 2\n",
    "plt.imshow(x_test_adv[6,...].squeeze())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "e6f7cb47",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe400466850>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAA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KkT+WsnOMrSqoaqeqvh593g/gg23GK3rujHGVRSWSfTqA90d9vRPVtd+7AnhBRFaLyJJKD2YMzaraGX3eBcDeA6n8vNt4l9MnthmvmnMXZ/vzpPgG3actVNXfAnAxgOuip6tVSUdeg1VT7XRc23iXyxjbjH+okucu7vbnSVUi2TsAzBj19bHRY1VBVTuij90AnkH1bUW964MddKOP3RUez4eqaRvvsbYZRxWcu0puf16JZH8NwBwROUFEagFcAeC5CozjU0RkQvTGCURkAoALUX1bUT8H4Oro86sBPFvBsXxMtWzj7dpmHBU+dxXf/lxVy/4PwGKMvCP/DoC/qsQYHOOaBeDN6N+GSo8NwOMYeVo3jJH3Nq4BMBXACgBbAPwXgMYqGttPAawDsBYjidVSobEtxMhT9LUA1kT/Flf63BnjKst54+2yRIHgG3REgWCyEwWCyU4UCCY7USCY7ESBYLITBYLJThSI/wdM/R8nbPyqZgAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# orig 5, guide 9\n",
    "plt.imshow(x_test_adv[8,...].squeeze())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "1489dc86",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe4003c1e50>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAT3UlEQVR4nO3dbZBU1ZkH8P8z3QOjMxIZwHGAUQRRl/gyxll8rcQtEkV2q9BkS6W2sm6kMm6MVcmaqtW4WxU+7Nbqlh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vMlz9X1ap/AZiFwSvy7wD4hyz64OjXZABvRV+bsu4bgBcx+LZuAIPXNuYCGANgGYDtAH4PoLmG+vafADYAWI/BxGrNqG83YPAt+noA3dHXrKxfO6NfVXndeLssUSB4gY4oEEx2okAw2YkCwWQnCgSTnSgQTHaiQDDZiQLx/2pINv+0JZ5zAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# orig 0, guide 8\n",
    "plt.imshow(x_test_adv[10,...].squeeze())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "18bc254a",
   "metadata": {},
   "source": [
    "\n",
    "## Unconstrained variant of Feature Adversaries\n",
    "\n",
    "This variant approximates the original hard constraint problem of the paper. Any available TensorFlow v2 optimizer can be used. We will use Adam as a good default one.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "70d9fbba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "32587adc1cd344bb8db3c36021245001",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Feature Adversaries TensorFlow v2:   0%|          | 0/100 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy on adversarial test batch: 0.0%\n",
      "Average perturbation: 0.17647060751914978%\n"
     ]
    }
   ],
   "source": [
    "# Step 6: Generate adversarial test examples\n",
    "attack = FeatureAdversariesTensorFlowV2(\n",
    "    classifier,\n",
    "    layer=-2,\n",
    "    delta=45/255,\n",
    "    optimizer=tf.keras.optimizers.Adam,\n",
    "    optimizer_kwargs={\"learning_rate\": 0.01},\n",
    "    lambda_=1.0,\n",
    "    max_iter=100,\n",
    "    random_start=True,\n",
    ")\n",
    "x_test_adv = attack.generate(source, guide)\n",
    "\n",
    "# Step 7: Evaluate the ART classifier on adversarial test examples\n",
    "\n",
    "predictions = classifier.predict(x_test_adv)\n",
    "accuracy = np.sum(np.argmax(predictions, axis=1) == np.argmax(y_test[:100][valid][:32], axis=1)) / len(y_test[:100][valid][:32])\n",
    "\n",
    "dim = tuple(range(1, len(source.shape)))\n",
    "pert = np.mean(np.amax(np.abs(source - x_test_adv), axis=dim))\n",
    "print(\"Accuracy on adversarial test batch: {}%\".format(accuracy * 100))\n",
    "print(\"Average perturbation: {}%\".format(pert))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "78e7ed4e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe40034dc40>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAT50lEQVR4nO3dbXBc1XkH8P9/dyXLkm1sWbasGBdjkEMMNHarMSmmDIQmQ2imQDtD4umkZIbWSQdmIMkHKPkQvpVpm0Cm00nHKZ6YDiGlTRj4QAvGpKWBxoOhAr8Vv8XCFpL8/m5h7e7TD1paBXSfI9+7b3D+vxmNVvvo3Hv2ah/d3X3uOYdmBhH5+Ms1ugMiUh9KdpFIKNlFIqFkF4mEkl0kEoV67qyV06wNHfXcpUhURnEG5+09ThbLlOwkbwbwfQB5AP9gZg97v9+GDlzDm7LsUkQcm2xjYiz1y3iSeQB/B+ALAJYBWE1yWdrtiUhtZXnPvhLAbjPba2bnAfwEwK3V6ZaIVFuWZF8IYP+Enw9U7vs1JNeQ3Exy8xjey7A7Ecmi5p/Gm9laM+szs74WTKv17kQkQZZkHwSwaMLPF1fuE5EmlCXZXwPQS/JSkq0Avgz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XiYSSXSQSda2zkzwEYOKczF0ADtetAxemWfvWrP0C1Le0qtm3S8xs3mSBuib7h3ZObjazvoZ1wNGsfWvWfgHqW1r16ptexotEQskuEolGJ/vaBu/f06x9a9Z+AepbWnXpW0Pfs4tI/TT6zC4idaJkF4lEQ5Kd5M0k3ya5m+QDjehDEpL7SG4h2U9yc4P7so7kQZJbJ9zXSXIDyV2V7/76vvXt20MkByvHrp/kLQ3q2yKSPye5neQ2kvdW7m/osXP6VZfjVvf37CTzAHYC+ByAAwBeA7DazLbXtSMJSO4D0GdmDb8Ag+T1AE4DeNzMrqrc91cAjprZw5V/lHPM7P4m6dtDAE43ehnvympFPROXGQdwG4CvooHHzunXHajDcWvEmX0lgN1mttfMzgP4CYBbG9CPpmdmLwP44PIftwJYX7m9HuNPlrpL6FtTMLMhM3ujcvsUgPeXGW/osXP6VReNSPaFAPZP+PkAmmu9dwPwAsnXSa5pdGcm0W1mQ5XbwwD8eaHqL7iMdz19YJnxpjl2aZY/z0of0H3YdWb2WwC+AODuysvVpmTj78GaqXY6pWW862WSZcb/TyOPXdrlz7NqRLIPAlg04eeLK/c1BTMbrHw/COBpNN9S1CPvr6Bb+e7PRllHzbSM92TLjKMJjl0jlz9vRLK/BqCX5KUkWwF8GcCzDejHh5DsqHxwApIdAD6P5luK+lkAd1Zu3wngmQb25dc0yzLeScuMo8HHruHLn5tZ3b8A3ILxT+T3APh2I/qQ0K8lAN6sfG1rdN8APInxl3VjGP9s4y4AcwFsBLALwIsAOpuob/8IYAuAtzCeWD0N6tt1GH+J/haA/srXLY0+dk6/6nLcdLmsSCT0AZ1IJJTsIpFQsotEQskuEgklu0gklOwikVCyi0TifwHLQSfI3WWTjgAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Step 8: Inspect results\n",
    "\n",
    "# orig 7, guide 6\n",
    "plt.imshow(x_test_adv[0,...].squeeze())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "dce73b0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe4003307f0>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAATJklEQVR4nO3dbYxc1XkH8P9/ZndtsB2/s3ZsBxvqgA0phmxIEagiQqWESDWoEoIPkSuhGFGoiJQPRVRqUD+hiiSK2iaqCQinTaGpCIJWKMGxotJAQ1mjxa9gG2OwzfoVg9cE2zszTz/sOFnM3ucM98ydO/b5/6TV7t5nzr3Hd/bxnZnnnnNoZhCRc1+l7A6ISGco2UUSoWQXSYSSXSQRSnaRRPR08mB9nGSTMaWThzwnsKeau63V6m3sSTqC5zxQxbJ6o429ad0JfIhTdpITxaKSneRNAL4PoArgR2b2kPf4yZiCL/OGmEMmqTpjlv8ATvjcAgDqh4+0uTdpCJ7z0Zobro+M+O0LKnm/bOszY7lfxpOsAvgnAF8FsBzAHSSX592fiBQr5j371QB2mtkuMzsF4EkAK9vTLRFpt5hkXwBgz7jf9za3fQzJ1SQHSQ6O4mTE4UQkRuGfxpvZGjMbMLOBXkwq+nAikiEm2fcBWDTu94XNbSLShWKS/RUAS0kuIdkH4HYAz7anWyLSbrlLb2ZWI3kvgF9grPT2mJlt8dqwtxc98z7xtv53anv9FwY9C7PbxgodO0bl8kvdeGPrDj/+wTH/AFcuywxVZ81wm9ZnRd738H/uUx6n4d8jUJ3tl8dql34uM8YXh9y29SPvuXG7doUbD+nZnv33Vj90KGrfmceMaWxmzwF4rk19EZEC6XZZkUQo2U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APrL7MwEgst4d9IZy4x3zbnLs/x5LH1A90nXmdlVAL4K4J7my9WuZGPvwbqpdtrSMt6dMsEy479T5rnLu/x5rDKSfR+AReN+X9jc1hXMbF/z+0EAT6P7lqI+cHoF3eb3rpkJs5uW8Z5omXF0wbkrc/nzMpL9FQBLSS4h2QfgdgDPltCPTyA5pfnBCUhOAXAjum8p6mcBrGr+vArAMyX25WO6ZRnvrGXGUfK5K335czPr+BeAmzH2ifybAP6mjD5k9OsiAK81v7aU3TcAT2DsZd0oxj7buBPAbADrAewA8EsAs7qob/8CYBOAjRhLrPkl9e06jL1E3whgqPl1c9nnzulXR86bbpcVSYQ+oBNJhJJdJBFKdpFEKNlFEqFkF0mEkl0kEUp2kUT8P4LUHEQP5VpBAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# orig 1, guide 5\n",
    "plt.imshow(x_test_adv[2,...].squeeze())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "8082690b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe400294370>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAUlElEQVR4nO3df2xd5XkH8O9zz3XsxE4gjhNjkkBCnKSELjjICz+H2NgQjSoFphWItC5IqO4vJlDZD8QqQSX+QBNth6aJKpSoacVSsVJKtKG2WVoNUSDEocHkB2li5jQxjh0SgpOQxL73PvvDh82A3+d1zrnn3pu9348U2b7Pfc95c+Mnx77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Sbp2O9gtVQ7nVQb70qZoM34/6rma5e0/Xla1Uj2fgDzx309L36sJqhqf/xxCMDzqL1W1IMfddCNP9pdJSuoltp4T9RmHDXw2lWz/Xk1kn0bgMUislBEpgC4C8CmKszjU0SkMX7jBCLSCOAW1F4r6k0A1safrwXwQhXn8jG10sbb1WYcVX7tqt7+XFUr/gfAKoy9I98L4B+qMQfHvC4D8Gb8Z1e15wZgI8Z+rBvF2Hsb9wCYBWALgH0A/hNAcw3N7UcA3gLQg7HEaqvS3G7A2I/oPQB2xH9WVfu1M+ZVkdeNt8sSBYJv0BEFgslOFAgmO1EgmOxEgWCyEwWCyU4UCCY7USD+B86BOEfKXe2wAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# orig 4, guide 9\n",
    "plt.imshow(x_test_adv[4,...].squeeze())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "a68f96b7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe40026dc70>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAUuUlEQVR4nO3de4xc1X0H8O93Znb9WNvgF2ZZGxs7y8MhxNCNSQJNSSkRoaogUYVCpIi2SU0KSCRFapDbKEiVKqctBNqkrkxx41SEiChQrIgGiCGlGGSwYcEvsPELbNZvjI2N1zszv/6xY7SBPb+zzJ0XOd+PtNrZ+5tz7/H1/PbOzu+ec2hmEJHffblmd0BEGkPJLpIIJbtIIpTsI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nnuql3+PKtmJPsuADOG/Dy9sq0lmNmuyve9AB5C6y1FvefkCrqV73ub3J/3tNIy3sMtM44WOHfNXP68Gcn+PIBukmeRbAfwFQDLm9CPDyDZUfngBCQ7AHwBrbcU9XIA11ceXw/g4Sb25be0yjLeoWXG0eRz1/Tlz82s4V8ArsLgJ/JbAPxtM/oQ6NdsAC9VvtY3u28A7sfg27oBDH628XUAkwGsALAZwK8BTGqhvv0XgLUAXsZgYnU2qW+XYvAt+ssAeitfVzX73Dn9ash50+2yIonQB3QiiVCyiyRCyS6SCCW7SCKU7CKJULKLJELJLpKI/wchwEKXmm7vJQAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# orig 4, guide 2\n",
    "plt.imshow(x_test_adv[6,...].squeeze())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "7a16e8fb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe4001d53d0>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAUWElEQVR4nO3de2yc1ZkG8OedS+zEuTpOjEkCueBSbiWACdeyrAI0ZVUFKi3btItAYuuqLVq6W1UgulLTRarQsrTqVkBlINtQLhUqpWR30UKaskJAGnCikIQEEmKSJcaXOBfHJHEyl3f/8IR1wec9w/fNjZznJ1kezzvn+04GP8x4znfOEVUFEZ38EtXuABFVBsNOFAiGnSgQDDtRIBh2okCkKnmycVKn9Wio5CmJgjKMwziux2SsWqyw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xm0ApgNYA2AHgD8AaKyhvv0awGYAmzASrJYq9e1KjLxF3wRgY+Hr+mo/d0a/KvK88XJZokDwAzqiQDDsRIFg2IkCwbATBYJhJwoEw04UCIadKBD/Bw41RT5v5T+iAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# orig 5, guide 9\n",
    "plt.imshow(x_test_adv[8,...].squeeze())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "8efcd647",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fe4001e7a30>"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAT2UlEQVR4nO3dfYyVVX4H8O/v3jszwADK8DKMgLwJKis62hFttcat0VWSBkkTlKaWbc2O266Jpv6hddNIk6bRVlc3zb6xK5XdbDF2VyNpbHcp2Uh9WWRgRxjeFgRcweGdlYHBmbl3fv1jHsygc35nfJ773Pvg+X4SMjP3N+d5Ds/Md+7LueccUVUQ0RdfrtodIKLKYNiJAsGwEwWCYScKBMNOFIhCJU9WK3U6AvWVPGXZSCHvrGmxFLttOfjOT+H4GGfQqz0yVC1R2EXkTgDfBpAH8CNVfdL6/hGoxw1yW5JTVk3+4gZnrXT8ROy25eA7P4Vjg65z1mI/jBeRPIDvALgLwDwAS0VkXtzjEVG6kjxnXwBgj6ruVdVeAC8CWFSebhFRuSUJ+xQAHwz6+kB023lEpFVE2kSkrQ89CU5HREmk/mq8qq5Q1RZVbalBXdqn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FsG9xlbNv01V1yDekVDTsnzm5SJuqtlStA4as9i2r/QLYt7gq1Tc+jCcKBMNOFIhqh31Flc9vyWrfstovgH2LqyJ9q+pzdiKqnGrfsxNRhTDsRIGoSthF5E4R2SUie0TksWr0wUVE9ovIVhFpF5G2KvdlpYgcEZGOQbc1iMhaEdkdfbQXra9s35aLyMHo2rWLyMIq9W2aiPxKRLaLyDYReSi6varXzuhXRa5bxZ+zi0gewG8B3A7gAICNAJaqaiY2xBaR/QBaVLXqb8AQkVsAnAbwY1W9KrrtXwCcUNUnoz+U41T10Yz0bTmA09Xexjvarahp8DbjAO4G8FVU8doZ/VqCCly3atyzLwCwR1X3qmovgBcBLKpCPzJPVdcDOPGpmxcBWBV9vgoDvywV5+hbJqhqp6pujj7vAnBum/GqXjujXxVRjbBPATB4L6YDyNZ+7wrglyKySURaq92ZITSqamf0+SEAjdXszBC823hX0qe2Gc/MtYuz/XlSfIHus25W1esA3AXgG9HD1UzSgedgWRo7HdY23pUyxDbjn6jmtYu7/XlS1Qj7QQCDVxKcGt2WCap6MPp4BMAryN5W1IfP7aAbfTxS5f58IkvbeA+1zTgycO2quf15NcK+EcAcEZkpIrUA7gWwpgr9+AwRqY9eOIGI1AO4A9nbinoNgGXR58sAvFrFvpwnK9t4u7YZR5WvXdW3P1fViv8DsBADr8i/B+Cb1eiDo1+zALwb/dtW7b4BWI2Bh3V9GHht434A4wGsA7AbwP8CaMhQ334CYCuALRgIVlOV+nYzBh6ibwHQHv1bWO1rZ/SrIteNb5clCgRfoCMKBMNOFAiGnSgQDDtRIBh2okAw7ESBYNiJAvH/m/0SgBY9f70AAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# orig 0, guide 8\n",
    "plt.imshow(x_test_adv[10,...].squeeze())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
